#define  _CRT_SECURE_NO_WARNINGS 1
//#include <stdio.h>
//int main()
//{
//	int a = 3;
//	int b = 5;
//	printf("%d %d\n", a, b);
//	b= a + b;
//	a = b - a;
//	b = b - a;
//	printf("%d %d\n", a, b);
//	return 0;
//}

#include <stdio.h>

int main()
{
    int year = 0;
    int month = 0;
    scanf("%d %d", &year, &month);
    if ((year % 4 != 0) && (year % 100 == 0) || (year % 400 == 0))
    {
        if (month == 2)
            printf("%d ", 28);
        if (month == 1)
            printf("%d ", 31);
        if (month == 3)
            printf("%d ", 31);
        if (month == 5)
            printf("%d ", 31);
        if (month == 7)
            printf("%d ", 31);
        if (month == 8)
            printf("%d ", 31);
        if (month == 10)
            printf("%d ", 31);
        else
            printf("%d ", 30);
    }
    else
    {
        if (month == 2)
            printf("%d", 29);
        if (month == 1)
            printf("%d ", 31);
        if (month == 3)
            printf("%d ", 31);
        if (month == 5)
            printf("%d ", 31);
        if (month == 7)
            printf("%d", 31);
        if (month == 8)
            printf("%d", 31);
        if (month == 10)
            printf("%d ", 31);
        else
            printf("%d ", 30);
    }
    return 0;
}
